/**
 * 
 */
package com.peycash.monitoring.persistencia.dao.impl;

import java.math.BigDecimal;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.Projections;
import org.springframework.stereotype.Repository;

import com.peycash.monitoring.dominio.ClientesRegPendientes;
import com.peycash.monitoring.persistencia.PersistenciaException;
import com.peycash.monitoring.persistencia.dao.CtesPdtesDAO;

/**
 * @author JAMARO
 *
 */
@Repository
public class CtesPdtesDAOImpl extends
		BaseDAOImpl<ClientesRegPendientes, BigDecimal> implements CtesPdtesDAO {

	@Override
	public List<String> findPendientes() throws PersistenciaException{
		try{
			Criteria criteria = getSessionFactory().getCurrentSession().createCriteria(ClientesRegPendientes.class);
			criteria.setProjection(Projections.property("noCel"));
			List<String> list = criteria.list();
			return list;
		}catch(Exception e){
			throw new PersistenciaException("Error en xx:"+e.getMessage(), e);
		}
	}
	
	@Override
	public void delete(String noCel) throws PersistenciaException{
		try{
			String hql = "delete from ClientesRegPendientes where noCel like :numCel ";
			Query query = getSessionFactory().getCurrentSession().createQuery(hql);
			query.setParameter("numCel", noCel);
			query.executeUpdate();
		}catch(Exception e){
			throw new PersistenciaException("Error en xx:"+e.getMessage(), e);
		}
	}
	
}
